namespace NetworkFlowMonitor.Scripts.Service;

// Models/Device.cs
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

public class Device
{
    [Key] public int Id { get; set; }

    [Required] public string MacAddress { get; set; }

    [Required] public string IpAddress { get; set; }

    public string? Remark { get; set; } = string.Empty;

    public int SpeedLimitKbps { get; set; }

    public bool IsBlocked { get; set; }

    public string? DeviceName { get; set; }

    public string? Manufacturer { get; set; }

    public DateTime FirstSeen { get; set; } = DateTime.UtcNow;

    public DateTime LastSeen { get; set; } = DateTime.UtcNow;

    public bool IsActive { get; set; } = true;
    // 导航属性
    public ICollection<TrafficRecord> TrafficRecords { get; set; } = new List<TrafficRecord>();
}

// Models/TrafficRecord.cs
public class TrafficRecord
{
    [Key] public int Id { get; set; }

    public int DeviceId { get; set; }

    public long BytesReceived { get; set; } // 下载流量
    public long BytesSent { get; set; } // 上传流量

    public DateTime Timestamp { get; set; } = DateTime.UtcNow;

    // 导航属性
    public Device Device { get; set; } = null!;
}

// Models/TrafficUpdate.cs
public class TrafficUpdate
{
    public string DeviceName { get; set; } = string.Empty;
    public string IpAddress { get; set; } = string.Empty;
    public string MacAddress { get; set; } = string.Empty;

    public string Remark { get; set; } = string.Empty;

    public int SpeedLimitKbps { get; set; }

    public bool IsBlocked { get; set; }
    public long DownloadSpeed { get; set; } // bytes per second
    public long UploadSpeed { get; set; } // bytes per second
    public long TotalDownload { get; set; }
    public long TotalUpload { get; set; }
    public DateTime Timestamp { get; set; }
}